﻿@model DLM.Web.ViewModel.PartyDetailPageView
@using Webdiyer.WebControls.Mvc;
@using Microsoft.Web.Helpers;
@using DLM.Web.MVC.Helper;
@{
    ViewBag.Title = "都来米-活动信息查看";
    Layout = "~/Views/Shared/_Master.cshtml";
}
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.form.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.rater.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.fancybox-1.3.4.pack.js")"></script>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/css/jquery.fancybox-1.3.4.css")" media="screen" />
<script type="text/javascript">
    $(document).ready(function () {
  
        
 
        $("#rdMessage").change(function () {
            var isChecked = $('input:radio[name="Salution.Type"]:checked').val();
            if (isChecked == null) {
                $("#txtMessage").css("display", "none");
            } else {
                $("#txtMessage").css("display", "block");
            }
        });


        $("#rdNormal").change(function () {
            $("#txtMessage").css("display", "none");
        });

        $("#rdFriend").change(function () {
            $("#txtMessage").css("display", "none");
        });

        $("ul.clearfix li").mouseover(function () {
            $(this).addClass("hover");
        });
        $("ul.clearfix li").mouseout(function () {

            $(this).removeClass("hover");
        });
        $("a").css("cursor", "pointer");

        var rate = parseFloat("@Model.SuccessRate");

        if ("@Model.PartyDTO.PartyType" == "1") {

            var engagedCount = parseFloat("@Model.Female") + parseFloat("@Model.Male");
            if (parseFloat("@Model.Female") < engagedCount / 3) {
                $("#btnAttend").attr("onclick", "");
                $("#btnAttend").click(function () {

                    $('#divMemberCaution').dialog('open');
                    return;
                });
            }
        }

    });


    $(function () {

        // Dialog			
        $('#dialog').dialog({
            autoOpen: false,
            disabled: false,
            width: 600,
            modal: true,


            buttons: {
                "确定": function () {
                    $("#frmPost").submit();

                },
                "关闭": function () {
                    $("#hdUserID").val("");
                    $(this).dialog("close");
                }
            }
        });

        $('#divPrint').dialog({
            autoOpen: false,
            disabled: false,
            width: 800,
            modal: true,


            buttons: {
                "打印": function () {

                    window.document.body.innerHTML = $("#divPrintContent").html();
                    window.print();

                },
                "关闭": function () {
                    $(this).dialog("close");
                }
            }
        });


        $('#divWarn').dialog({
            autoOpen: false,
            disabled: false,
            width: 400,
            modal: true,


            buttons: {
                "确定": function () {
                    window.location.href = "/Party/Attend/@Model.PartyDTO.PartyID";

                },
                "取消": function () {
                    $("#hdUserID").val("");
                    $(this).dialog("close");
                }
            }
        });

        $('#divMemberCaution').dialog({
            autoOpen: false,
            disabled: false,
            width: 400,
            modal: true,


            buttons: {
                "确定": function () {
                    window.location.href = "/Party/Attend/@Model.PartyDTO.PartyID";

                },
                "取消": function () {
                    $("#hdUserID").val("");
                    $(this).dialog("close");
                }
            }
        });

        $('.hi').click(function () {
            if (checkAuth()) {
                $("#divMessage").html("");
                $('#dialog').dialog('open');
                return false;
            } else {
                ShowDialogMessage("warn", "您还没登录，请先登录！");
                window.location.href = "/Account/Login?ReturnUrl=/Party/View/@Model.PartyDTO.PartyID";
                return false;
            }

        });

    });

    function showPrint() {
        $('#divPrint').dialog('open');
    }

    function setUser(item) {
        if ("@Request.IsAuthenticated" != "False") {
            $("#hdUserID").val(item);
        }
    }

    function checkAuth() {
        if ("@Request.IsAuthenticated" == "True") {
            return true;
        } else {
            return false;
        }
    }

    function validateApply() {
        if (!checkAuth()) {
            ShowDialogMessage("warn", "您还没登录，请先登录！");
            window.location.href = "/Account/Login?ReturnUrl=/Party/View/@Model.PartyDTO.PartyID";
            return false;
        }
    }

    function onSuccessed() {
        ShowDialogMessage('right', "操作成功，请等待该会员的回应！");
    }

    function onGreetFalied(ajaxContext) {
        ShowDialogMessage("warn", ajaxContext.responseText);
        //ShowDialogMessage('warn', "或许您已经打过招呼了，请耐心等待回应！");

    }

    function onInvitateFalied(ajaxContext) {
        ShowDialogMessage("warn", ajaxContext.responseText);
    }

    function onInvitateSuccessed() {
        ShowDialogMessage('right', "操作成功了，请等待该会员的回应！");
    }

    function onQuitSuccess() {
        ShowDialogMessage('right', "活动退出成功！");
        window.location.reload(true)
    }

    function onQuitFailure(ajaxContext) {
        ShowDialogMessage('error', "操作失败了,请重试或者联系管理员！");
    }

    function onSubmitSuccessed() {
        $("#hdRate").val(100);
        $("#rater_1").hide();
        //$("#rater_1").css("display", "none");
        _reloadMvcCaptchaImage();
        $("#rateTitle").html("您已经对此次活动评分了，不能重复评分,可以继续发表您的评论");
        //$("#btnSubmitRemark").attr("disabled", "disabled");

    }

    function onSubmitRemarkFailure(ajaxContext) {
       _reloadMvcCaptchaImage();
        ShowDialogMessage("warn", ajaxContext.responseText);
       
    }


        $(document).ready(function () {
        var options = {
            target: '#divPartyAlbum',
            success: showResponse

        };
        $('#albumPost').submit(function () {
            $(this).ajaxSubmit(options);
            return false;
        });
    });


    function showRequest(formData, jqForm, options) {

        return true;
    }

    function showResponse(responseText, statusText) {
        if (responseText != "您上传的照片格式不符合要求,请上传jpg格式的图片"
        && responseText != "请选择要上传的照片"
        && responseText != "系统最多允许上传八张相片") {
        } else {
             //$("#divPartyAlbum").html("");
            $("#divPartyAlbum").load("@Url.Action("GetPartyAlbum", new { id = Model.PartyDTO.PartyID })");
             ShowDialogMessage('warn', responseText);      
        }
      
    }

        function showPhoto(obj){
            $(obj).fancybox({
				'opacity'		: true,
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
                });
            return false;
        }

</script>
<div id="dialog" title="打个招呼">
    <div class="dialog_box">
        <div class="hi_box">
            @*  <p>
                下次登录后将会收到通知.</p>*@
            @using (Ajax.BeginForm("Greet", "Friend", new { greetID = 1 }, new AjaxOptions { HttpMethod = "Post", OnFailure = "onGreetFalied", OnSuccess = "onSuccessed" }, new { id = "frmPost" }))
            {
                <div id="">
                    打招呼需要您付出两分的积分，索要联系方式需要五分，不成功不会扣除积分
                </div>
                <ul>
                    <li>
                        @Html.RadioButtonFor(m => m.Salution.Type, (int)DLM.Domain.Model.GreetType.Normal, new { @class = "radio", id = "rdNormal" })<i
                            class="hi_1"></i>Hi,你好呀~ @*<input type="radio" class="radio" name="hi" /><i class="hi_1"></i>Hi,你好呀~*@</li>
                    <li>
                        @Html.RadioButtonFor(m => m.Salution.Type, (int)DLM.Domain.Model.GreetType.Friend, new { @class = "radio", id = "rdFriend" })<i
                            class="hi_2"></i>有好感</li>
                    @if (Request.IsAuthenticated && Model.IsAttend && Model.PartyDTO.Status == (int)DLM.Domain.Model.PartyStatus.Closed && DateTime.Now <= Model.PartyDTO.PartyDate.Value.AddDays(+14))
                    {
                        <li>
                            @Html.RadioButtonFor(m => m.Salution.Type, (int)DLM.Domain.Model.GreetType.Phone, new { @class = "radio", id = "rdMessage" })<i
                                class="hi_3">
                                @Html.TextBoxFor(m => m.Salution.Message, new { @class = "text", id = "txtMessage", name = "txtMessage", style = "display:none;", maxlength = "20" })
                            </i>索要联系方式 </li>
                        
                    }
                    else
                    {
                        <li><i class="hi_3"></i>请在参加活动后所要该会员的联系方式! </li>
                    }
                </ul>
                <input type="hidden" name="hdUserID" id="hdUserID" />
               
            }
        </div>
    </div>
</div>
<div class="main">
    <!--查看活动详情-->
    @if (Model.PartyDTO.Status != (int)DLM.Domain.Model.PartyStatus.PendingForApproval || (Request.IsAuthenticated && Model.IsLead == true))
    { 
        <div class="act_info">
            <div class="a1 clearfix">
                <div class="a1_pic">
                    @switch (Model.PartyDTO.PartyType)
                    {
                        case 0:
                               
                        <img src="@Url.Content("~/Content/ad/act_pop_sport.png")" />
                             break;
                        case 1:
                           
                        <img src="@Url.Content("~/Content/ad/act_pop_sport_blind.png")" />
                             break;
                        case 2:
                        @Html.Label("老乡交友");
                        <img src="@Url.Content("~/Content/ad/act_pop_sport_vi.png")" />
                             break;
                        case 3:
                        <img src="@Url.Content("~/Content/ad/act_pop_sport_other.png")" />
                             break;
                        default:
                        <img src="@Url.Content("~/Content/ad/act_pop_sport_other.png")" />
                             break;
                    }
                </div>
                <div class="a1_info">
                    <h2>
                        @Html.Label(Model.PartyDTO.Subject)</h2>
                    <div class="tr clearfix">
                        <div class="creater">
                            <table>
                                <tr>
                                    <td>
                                        <span>活动发起人:</span>
                                    </td>
                                    <td>
                                        @if (Model.PartyDTO.PublisherPhoto == "none_75_75.png")
                                        {
                                            <img src="@Url.Content("~/Content/ad/none_45_45.png")" alt="头像" width="51" height="51" />
                                        }
                                        else
                                        { 
                                            <img src="@Url.Content("~/Files/Photos/" + Model.PartyDTO.UserID + "/Title/" + Model.PartyDTO.PublisherPhoto)" alt="头像" width="51" height="51" />
                                        }
                                    </td>
                                    <td>
                                        <a style="cursor: pointer" href="@Url.Action("View", "User", new { id = Model.PartyDTO.UserID })">@Model.PartyDTO.PublishAccount</a><br />
                                        @if (Model.PartyDTO.Status == (int)DLM.Domain.Model.PartyStatus.Freeze && (Model.IsAttend || Model.IsAttend))
                                        {   <a style="cursor: pointer">@Model.PartyDTO.Phone</a>
                                        }
                                        else
                                        {
                                            <span>活动冻结后，可以查看发布人联系电话</span> 
                                        }
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="tr clearfix">
                        <div class="rate_div">
                            <span>发起者发起成功率:</span>
                            @{ var rate = Model.SuccessRate * 100;}
                            @rate % &nbsp; 发起 @Model.Statistics[0]次, 成功 @Model.Statistics[1] 次
                        </div>
                    </div>
                    <div class="tr clearfix">
                        <span>活动类型:</span>
                        @switch (Model.PartyDTO.PartyType)
                        {
                            case 0:
                                @Html.Label("体育活动");
                                break;
                            case 1:
                            @Html.Label("单身男女");
                                               break;
                            case 2:
                            @Html.Label("老乡交友");
                                               break;
                            case 3:
                            @Html.Label("其他活动");
                                               break;
                            default:
                            @Html.Label("其他活动");
                                               break;
                        }
                    </div>
                    <div class="tr clearfix">
                        <span style="color: Red;">注意:"体育活动"并非专门针对单身男女;"单身男女活动"则可以是体育类活动!</span></div>
       @*        <div class="tr clearfix">
                        <span>活动形式:</span> @Html.DisplayFor(model => model.PartyDTO.Modality)</div>*@
                    <div class="tr clearfix">
                        <span>开始时间:</span> @Html.DisplayFor(model => model.PartyDTO.PartyDate)</div>
                    <div class="tr clearfix">
                        <span>结束时间:</span> @Html.DisplayFor(model => model.PartyDTO.EndDate)</div>
                    <div class="tr clearfix">
                        <span>活动地点:</span> @Html.DisplayFor(model => model.PartyDTO.Location)</div>
                    <div class="tr clearfix">
                        <span>详细地址:</span> @Html.DisplayFor(model => model.PartyDTO.Address)</div>
                    <div class="tr clearfix">
                        <span>已报名人数:</span> @Model.Male 男
                        @Model.Female 女
                    </div>
                    <div class="tr clearfix">
                        <span>限制人数:</span>@Html.DisplayFor(model => model.PartyDTO.MemberCount)</div>
                    @if (Model.PartyDTO.PartyType == (int)DLM.Domain.Model.PartyType.HomeTown)
                    { 
                        <div class="tr clearfix">
                            <span>活动范围:</span>
                            @Html.DisplayFor(model => model.PartyDTO.Area)</div>
                    }
                    <div class="tr clearfix">
                        <span>预估费用:</span>@Html.DisplayFor(model => model.PartyDTO.Expense)
                    </div>
                    <div class="tr clearfix">
                        <span>支付类型:</span>
                        @switch (Model.PartyDTO.PaymentType)
                        {

                            case 1:
                            @Html.Label("男女AA");
                                               break;
                            case 2:
                            @Html.Label("男士AA女士免费");
                                                   break;
                            case 3:
                            @Html.Label("男士人均比女士多一倍");
                                                     break;
                            default:
                            @Html.Label("其他");
                                             break;
                        }
                    </div>
                    <div class="tr clearfix">
                        @switch (Model.PartyDTO.Status)
                        {

                            case 0:
                            <div class="status free">
                                活动状态: @Html.Label("火热报名中")</div>
                                 break;
                            case 1:
                            <div class="status end">
                                活动状态: @Html.Label("活动结束")
                            </div>
                       
                                 break;
                            case 2:
                            <div class="status end">
                                活动状态: @Html.Label("活动冻结，停止报名")
                            </div>
                      
                                 break;
                            case 4:
                            <div class="status end">
                                活动状态: @Html.Label("活动取消")
                            </div>
                      
                                 break;
                            case 5:
                            <div class="status end">
                                活动状态: @Html.Label("审核未通过")
                            </div>
                      
                                 break;
                            default:
                            <div class="status end">
                                活动状态: @Html.Label("活动审核中")
                            </div>
                                 break;
                        }
                    </div>
                    @if (User.Identity.IsAuthenticated)
                    {
                        if (Model.PartyDTO.Status != (int)DLM.Domain.Model.PartyStatus.Closed && Model.PartyDTO.Status != (int)DLM.Domain.Model.PartyStatus.Freeze && Model.PartyDTO.Status != (int)DLM.Domain.Model.PartyStatus.Cancel && Model.PartyDTO.Status != (int)DLM.Domain.Model.PartyStatus.PendingForApproval)
                        {
                        <div class="tr clearfix operate">
                            @using (Ajax.BeginForm("Quit", "Party", new { partyID = Model.PartyDTO.PartyID }, new AjaxOptions { HttpMethod = "Post", OnSuccess = "onQuitSuccess", OnFailure = "onQuitFailure" }))
                            {
                                if (!Model.IsLead && !Model.IsAttend)
                                {
                                @Html.ActionLinkButton("加入", "Attend", "Party", new RouteValueDictionary(new { id = @Model.PartyDTO.PartyID }), "btn join", "btnAttend")


                        
                                }
                                if (Model.IsAttend || Model.IsLead)
                                {
                                @Html.ActionLinkButton("邀请好友", "Invitation", "Party", new RouteValueDictionary(new { party = @Model.PartyDTO.PartyID }), "btn favirate", "btnInvitate")




                               
                             
                            
                                  



                                }
                                if (Model.IsAttend && !Model.IsLead)
                                {
                                <input type="submit" class="btn quit" value="退出" />
                                }

                                if (Model.IsAttend)
                                { 
                                @Ajax.ActionLink("打印会员资料", "Print", "Party", new { partyID = Model.PartyDTO.PartyID }, new AjaxOptions { HttpMethod = "Post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "divPrintContent", OnSuccess = "showPrint" })

                                }


                            }
                        </div>
                        }
                    }
                    else
                    {
                        <div class="tr clearfix">
                            <div class="attention_2">
                                <a href="/Account/Login?ReturnUrl=/Party/View/@Model.PartyDTO.PartyID">请登录后报名参加活动</a></div>
                        </div>
                    }
                </div>
            </div>
            <div class="a2 album" style="display: none;">
                <a href="#">上传活动照片</a></div>
            <div class="a3">
                <h6>
                    [活动内容]</h6>
                @Model.PartyDTO.Content
                @*   <div class="attention">
                   </div>*@
            </div>
            <div class="a4">
                <div class="notice_st">
                    <h6>
                        [报名流程提示]</h6>
                    <ol>
                        <li>1.进主页面寻找（亦可搜索）您感兴趣的活动（或在您登陆后的页面点“我可能感兴趣的活动”），点击参加即可。</li>
                        <li>2.个人信息完善
                            <br />
                            a. 为保证会员之间资料的对等性，活动可能需要您完善某些个人资料（比如单身男女活动需要添加额外的信息才能参加）。<br />
                            b. 网站将不定时对某些人群赠送积分。同时开放支付宝积分充值功能。<br />
                            c. 活动发起者的联系方式只在活动冻结后公开，用以实际活动到场联络。 </li>
                        <li>3.都来米不是一个来去完全自由的活动平台。因“放鸽子”、私自带人等行为将影响活动计划甚至导致活动失败，网站将对此进行积分扣除和帐号限制等惩罚。积分细则详见《报名须知》。
                            <br />
                            网站将不定时对某些人群赠送积分。同时开放支付宝积分充值功能。 </li>
                        <li>4.活动举行前（通常在活动举行前72到48小时）网站将和活动报名者电话确认并据此对活动冻结或解散。此间联系不上的会员将视为未报名参加此活动。为促成活动成功，都来米网工作人员可能就活动冻结、活动反馈等和参加者进行电话沟通，不便之处请原谅。</li>
                        <li>5.任何时候，对网络资料和实际活动所见真人有较大出入时，请及时拨打投诉热线：18221800674,1502962320</li>
                        <li>6.活动结束后活动论坛开放，同时向该活动已参加者开通“索要联系方式”功能（“我的招呼”项下）</li>
                    </ol>
                </div>
            </div>
            <div class="a5">
                <div class="member">
                    <h6>
                        [参加者]</h6>
                    <div id="divParticipant" class="tr clearfix">
                        @{Html.RenderPartial("_Participant", Model.Users);}
                    </div>
                </div>
            </div>
            @if (Request.IsAuthenticated)
            {
            
                <script type="text/javascript">

                    $(document).ready(function () {
                        //jqueryRater
                        var options = { max: 10 }
                        $('#rater_1').rater(options);
                    })
                </script>

                if (Model.PartyDTO.Status == (int)DLM.Domain.Model.PartyStatus.Closed)
                {
                    if (Request.IsAuthenticated && (Model.IsAttend || Model.IsLead))
                    {
                        using (Html.BeginForm("UploadPartyPhoto", "Party", new { id = Model.PartyDTO.PartyID }, FormMethod.Post, new { enctype = "multipart/form-data", id = "albumPost" }))
                        {
                            { Html.RenderPartial("_PartyAlbum", Model); }
                        }
                    }
                }

                if (Model.PartyDTO.Status == (int)DLM.Domain.Model.PartyStatus.Closed)
                {
                    if (Request.IsAuthenticated)
                    {
           
                <div class="a6">
                    <div id="divSubmitRemark" class="visiter_book">
                        <h6>
                            [活动留言]<span>共
                                @Model.Remarks.Count() 条留言</span></h6>
                        @using (Ajax.BeginForm("SubmitRemark", "Party", new { id = Model.PartyDTO.PartyID }, new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "Post", UpdateTargetId = "divRemark", OnSuccess = "onSubmitSuccessed", OnFailure = "onSubmitRemarkFailure" }))
                        {
                            <div class="content clearfix">
                                @Html.TextArea("txtContent")
                                <div class="marking">
                                    @if (Model.CanLeaveMessage)
                                    {
                                        
                                        <div class="marking_box">
                                            <h3 id="rateTitle">
                                                你对此次活动的评价<span style="color: Red;">点击打分(必填)</span></h3>
                                            <div id="rater_1">
                                            </div>
                                            @Html.Hidden("hdRate", "", new { @id = "hdRate" })
                                            <input type="hidden" name="hdIsRate" id="hdIsRate" value="True" />
                                        </div>
                                    }
                                    else
                                    {
                                        <div class="marking_box">
                                            <h3>
                                                您已经对此次活动评分了，不能重复评分,可以继续发表您的评论</h3>
                                            <input type="hidden" name="hdIsRate" id="hdIsRate" value="False" />
                                        </div>
                                    }
                                </div>
                            </div>
                            <div class="submit">
                                <script type="text/javascript">
                                    $(document).ready(function () { _reloadMvcCaptchaImage(); });
                                   
                                </script>
                                @Html.MvcCaptcha(new MvcCaptchaOptions { DelayLoad = true, ValidationInputBoxId = "_mvcCaptchaText", CaptchaImageContainerId = "captchaImage" })
                                <span id="captchaImage"></span>
                                <br />
                                <br />
                                <input type="text" name="_mvcCaptchaText" id="_mvcCaptchaText" />
                                @*  @ReCaptcha.GetHtmlWithOptions("6LdYRtESAAAAADcIZ3q-Mtr90XPyaYq82gnet-n5", "6LdYRtESAAAAAInpSF9yl6Z2awmd8-hYgXfc7Rvg")*@
                                <input id="btnSubmitRemark" type="submit" value="提交" class="btn" />
                            </div>
                        
                        }
                    </div>
                </div>
                    }
                    else
                    {
                <div class="a6">
                    <div class="tr clearfix">
                        <div class="attention_2">
                            您没有参加该活动，只能查看该活动的评论</div>
                    </div>
                </div>
                    }
                
                <div class="a6">
                    <div id="divRemark">
                        @{Html.RenderPartial("_Remark", Model.Remarks);}
                    </div>
                </div>
              
          
                }
            }
            else
            {
                <div class="a6">
                    <div class="tr clearfix">
                        <div class="attention_2">
                            请在活动结束后发表您的体会和感受</div>
                    </div>
                </div>
            }
        </div>
    }
</div>
<div id="divPrint" title="打印">
    <div class="dialog_box">
        <!--startprint-->
        <div id="divPrintContent" class="hi_box">
        </div>
    </div>
    <!--endprint-->
</div>
<div id="divWarn" title="活动参加提醒">
    <div class="dialog_box">
        <div id="divWarnMessage" class="hi_box">
            该活动的举办者活动举办成功率低于50%，您确认要参加吗？
        </div>
    </div>
</div>
<div id="divMemberCaution" title="活动参加提醒">
    <div class="dialog_box">
        <div id="divWarnMessage" class="hi_box">
            目前报名的女生偏少,确认继续参加？
        </div>
    </div>
</div>
